package com.zeei.ems.meet.hik;

import com.fasterxml.jackson.core.type.TypeReference;
import com.zeei.ems.base.util.JsonUtil;
import com.zeei.ems.meet.util.JackSonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class HikVisionVideoNmsClient {

    private final String ARTEMIS_PATH = "/artemis";

    @Autowired
    HikConfig hikConfig;

    //获取监控点在线状态
    public ListResponse<CameraOnlineDto> getCameraOnline(NmsGetRequest getRequest) {
        String getDataApi = ARTEMIS_PATH + "/api/nms/v1/online/camera/get";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("http://", getDataApi);
            }
        };
        String body = JsonUtil.object2json(getRequest);
        String result = CustomArtemisHttpUtil.doPostStringArtemis(path, body, null, null, "application/json", hikConfig);
        ListResponse<CameraOnlineDto> encodeDeviceDtoListResponse = JackSonUtil.readValue(result, new TypeReference<ListResponse<CameraOnlineDto>>() {});
        return encodeDeviceDtoListResponse;
    }
}
